import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
    public class _27 {

        public static void text04() {
            ChromeOptions options = new ChromeOptions();
            options.addArguments("remove-allow-origins");
            WebDriver webDriver = new ChromeDriver();
            webDriver.get("https://www.baidu.com");
            String s = webDriver.findElement(By.cssSelector("#su")).getAttribute("value");
            if (s.equals("百度一下")) {
                System.out.println("测试通过");
            } else {
                System.out.println(s);
                System.out.println("测试不通过");
            }
        }

        public static void text03() {//submit&#x7684;&#x5F0A;&#x7AEF;
            ChromeOptions options = new ChromeOptions();
            options.addArguments("remove-allow-origins");
            WebDriver webDriver = new ChromeDriver();
            webDriver.get("https://www.baidu.com");
            //webDriver.findElement(By.xpath("//a[text()=\"新闻\"]")).submit();//submit点击元素没在from元素中则不会生效，甚至报错；
            //webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.DAYS);//隐式等待
            webDriver.findElement(By.xpath("//a[text()=\"新闻\"]")).click();//利用click点击可以实现；
        }

        public static void text02() {//利用clear清空搜索框中的数据
            ChromeOptions options = new ChromeOptions();
            options.addArguments("remove-allow-origins");
            WebDriver webDriver = new ChromeDriver();
            webDriver.get("http://www.baidu.com");
            webDriver.findElement(By.cssSelector("#kw")).sendKeys("前端vue");
            webDriver.findElement(By.cssSelector("#su")).click();//点击按钮
            webDriver.findElement(By.cssSelector("#kw")).clear();//清空搜索框里的数据
        }
    }
